<html>
<head><meta charset="utf-8"><title>named explicit registers · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html">named explicit registers</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="200304825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200304825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200304825">(Jun 09 2020 at 23:39)</a>:</h4>
<p>Attempting to name an explicit register fails with: <code>error: explicit register arguments cannot have names</code></p>
<p>From a legibility point of view, it is massively helpful to refer to a parameter by a semantically relevant name, rather than be forced to use positional notation.  Also, the result is far less fragile when one new parameter is added in the middle of the parameter list.</p>
<p>i.e. I think <a href="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=ee34edb56e06d922e1352984b50a813c">https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=ee34edb56e06d922e1352984b50a813c</a> out to compile and work just fine</p>



<a name="200304892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200304892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200304892">(Jun 09 2020 at 23:40)</a>:</h4>
<p>Nit: you need a comma between <code>{x}</code> and <code>4</code>.</p>



<a name="200304929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200304929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200304929">(Jun 09 2020 at 23:41)</a>:</h4>
<p>:) fair enough, but the point still stands</p>



<a name="200305490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305490">(Jun 09 2020 at 23:49)</a>:</h4>
<p>But otherwise, yes, I understand. I personally would like to see this work as well.</p>



<a name="200305625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305625">(Jun 09 2020 at 23:51)</a>:</h4>
<p>You said, though, "rather than be forced to use positional notation". Positional notation for explicit register arguments was actually intentionally disallowed, on the theory that it would be potentially error-prone. I do, however, think that <em>named</em> notation for explicit register arguments seems perfectly fine.</p>



<a name="200305744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305744">(Jun 09 2020 at 23:53)</a>:</h4>
<p>ah - that would explain the other error I was seeing.</p>



<a name="200305753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305753">(Jun 09 2020 at 23:53)</a>:</h4>
<p>Also, one other note on that example: if you're trying to add to <code>i</code>, you shouldn't have the <code> =&gt; _</code> . You just want <code>inout("rax") i</code>.</p>



<a name="200305802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305802">(Jun 09 2020 at 23:54)</a>:</h4>
<p><code>inout("rax") i =&gt; _</code> says that i goes in and nothing comes out, so the value of <code>i</code> doesn't change.</p>



<a name="200305824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305824">(Jun 09 2020 at 23:54)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=267caf25b2a6010a36c4848acee1b485">https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=267caf25b2a6010a36c4848acee1b485</a></p>



<a name="200305832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305832">(Jun 09 2020 at 23:54)</a>:</h4>
<p>that was actually what I intended at the time, but I shouldn't have confused my examples</p>



<a name="200305847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305847">(Jun 09 2020 at 23:55)</a>:</h4>
<p>Ah, OK.</p>



<a name="200305853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305853">(Jun 09 2020 at 23:55)</a>:</h4>
<p>I'm experimenting with translating <a href="https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e952f1d67b5641bb560fbff6b80555808faf7935">https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e952f1d67b5641bb560fbff6b80555808faf7935</a> into this new assembly, because someone's going to have to do it at some point</p>



<a name="200305868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305868">(Jun 09 2020 at 23:55)</a>:</h4>
<p>Awesome!</p>



<a name="200305873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305873">(Jun 09 2020 at 23:55)</a>:</h4>
<p>the local .Ldone label doesn't have an obvious translation at all</p>



<a name="200305924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305924">(Jun 09 2020 at 23:56)</a>:</h4>
<p>its specifically not 1f because that collides with the middle of the .rept block</p>



<a name="200305938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305938">(Jun 09 2020 at 23:56)</a>:</h4>
<p>You could make it <code>5f</code> and label it <code>5:</code>, but yeah, it's annoying that you can't name it.</p>



<a name="200305977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305977">(Jun 09 2020 at 23:57)</a>:</h4>
<p>numbered labels are concerning fragile</p>



<a name="200305984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305984">(Jun 09 2020 at 23:57)</a>:</h4>
<p>No argument there whatsoever.</p>



<a name="200305991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200305991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200305991">(Jun 09 2020 at 23:57)</a>:</h4>
<p>There <em>should</em> be a way to define local named labels.</p>



<a name="200306059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306059">(Jun 09 2020 at 23:58)</a>:</h4>
<p>(I'm also suffering from having a massive AT&amp;T preference, but I guess that's a can of worms not worth opening at this point)</p>



<a name="200306077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306077">(Jun 09 2020 at 23:58)</a>:</h4>
<p>Please feel free, especially in an initial translation, to do <code>options(att_syntax)</code>.</p>



<a name="200306081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306081">(Jun 09 2020 at 23:58)</a>:</h4>
<p>That way you're only translating one thing at a time. :)</p>



<a name="200306093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306093">(Jun 09 2020 at 23:59)</a>:</h4>
<p>I also fully expect some projects to define a macro <code>asm_att!</code> to do exactly that. Which reminds me, I need to test something...</p>



<a name="200306327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306327">(Jun 10 2020 at 00:02)</a>:</h4>
<p>aah.  Ok - there is a very confusing error</p>



<a name="200306343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306343">(Jun 10 2020 at 00:03)</a>:</h4>
<p>Compiling playground v0.0.1 (/playground)<br>
error: expected token: <code>,</code><br>
 --&gt; src/main.rs:8:14<br>
  |<br>
8 |              "mov    $1, {ssp}           \n\t"<br>
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected <code>,</code></p>
<p>actually means "you don't have a parameter named {ssp} yet"</p>



<a name="200306474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306474">(Jun 10 2020 at 00:05)</a>:</h4>
<p>Oh, that's fun.</p>



<a name="200306484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306484">(Jun 10 2020 at 00:05)</a>:</h4>
<p>Regarding writing an <code>asm_att!</code> macro: <a href="https://github.com/rust-lang/rust/issues/73193">https://github.com/rust-lang/rust/issues/73193</a></p>



<a name="200306582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306582">(Jun 10 2020 at 00:07)</a>:</h4>
<p><span class="user-mention" data-user-id="310469">@Andrew Cooper</span> I just tested, and I can't reproduce that. I got:</p>
<div class="codehilite"><pre><span></span><code>error: there is no argument named `foo`
</code></pre></div>



<a name="200306598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306598">(Jun 10 2020 at 00:07)</a>:</h4>
<p>Can you provide a full example reproducing that?</p>



<a name="200306643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306643">(Jun 10 2020 at 00:08)</a>:</h4>
<p>yeah - I'm confused.  It doesn't seem to like it even with {ssp} explicitly named</p>



<a name="200306654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306654">(Jun 10 2020 at 00:08)</a>:</h4>
<p>Ohhhhhhh.</p>



<a name="200306659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306659">(Jun 10 2020 at 00:08)</a>:</h4>
<p>Rust doesn't do automatic string concatenation.</p>



<a name="200306673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306673">(Jun 10 2020 at 00:09)</a>:</h4>
<p>If you wrote <code>"foo\n\t" "bar\n\t"</code> , Rust will not concatenate those, it'll complain at the second one saying it expected a comma.</p>



<a name="200306684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306684">(Jun 10 2020 at 00:09)</a>:</h4>
<p>Rust has multi-line strings.</p>



<a name="200306711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306711">(Jun 10 2020 at 00:09)</a>:</h4>
<p>(Or if you <em>really</em> want to, you should be able to use <code>concat!</code>, but personally I'd suggest multi-line strings.)</p>



<a name="200306778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306778">(Jun 10 2020 at 00:10)</a>:</h4>
<p>aah</p>



<a name="200306909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306909">(Jun 10 2020 at 00:12)</a>:</h4>
<p>that's one part of GCC inline assembly I'm not going to miss</p>



<a name="200306951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200306951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200306951">(Jun 10 2020 at 00:13)</a>:</h4>
<p>although actually, it does mean you can't comment your large asm blocks.  hmm :S</p>



<a name="200307237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200307237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200307237">(Jun 10 2020 at 00:18)</a>:</h4>
<p>oh that's neat - it does translate comment markers in the inline asm.</p>



<a name="200307459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200307459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200307459">(Jun 10 2020 at 00:21)</a>:</h4>
<p>but it also attempts to translate them before knowing that they are comments<br>
//lea    .Ldone(%rip), {rip}<br>
error: there is no argument named <code>rip</code></p>



<a name="200307533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200307533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200307533">(Jun 10 2020 at 00:23)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> local named labels do work when I'm not suffering from the multiline string issue</p>



<a name="200308040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200308040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200308040">(Jun 10 2020 at 00:31)</a>:</h4>
<p>ok - end result is <a href="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=a77ba2476a56c9bc2d4da0d651414637">https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=a77ba2476a56c9bc2d4da0d651414637</a> which isn't too bad</p>



<a name="200308126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200308126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200308126">(Jun 10 2020 at 00:33)</a>:</h4>
<p>one note.  the RFC says that the widest register option is always picked, but that isn't true for <code>cs = in(reg) 0xe008</code>, which LLVM tries to shrink to its 32bit form, subsequently hitting issues with both <code>wrsspq</code> and <code>push</code>.</p>



<a name="200308143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200308143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200308143">(Jun 10 2020 at 00:33)</a>:</h4>
<p>I don't expect this to be a problem in practice, because the diagnostic is clear as to what the ambiguity is, and how to resolve it</p>



<a name="200308890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200308890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200308890">(Jun 10 2020 at 00:47)</a>:</h4>
<p>Still, report it if unclear.</p>



<a name="200309076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200309076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200309076">(Jun 10 2020 at 00:51)</a>:</h4>
<p>what about memory operands?</p>



<a name="200309092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200309092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200309092">(Jun 10 2020 at 00:51)</a>:</h4>
<p>instructions such as <code>ldmxcsr</code> strictly only take a memory operand, and I cant find a way of expressing that</p>



<a name="200309171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200309171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Cooper <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200309171">(Jun 10 2020 at 00:53)</a>:</h4>
<p>best I can see is to take the value by register, push it onto the stack, and use an %rsp reference,  but this is the kind of thing the compiler ought to be arranging, rather than the programmer</p>



<a name="200311318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200311318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200311318">(Jun 10 2020 at 01:32)</a>:</h4>
<p>Put the address in a register and write <code>[{reg}]</code>.</p>



<a name="200312610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200312610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200312610">(Jun 10 2020 at 01:58)</a>:</h4>
<p><span class="user-mention" data-user-id="310469">@Andrew Cooper</span> The rationale for not supporting substitution for explicit registers is that it can be a bit counter-intuitive. Even though you specify the register name in the operand (<code>in("eax")</code>) the compiler will actually ignore that and use the size of the value you passed in (<code>i64</code> for example) to determine the register name to use in the asm (<code>rax</code> in this case, instead of the <code>eax</code> you specified).</p>



<a name="200381539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200381539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200381539">(Jun 10 2020 at 06:12)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> I'm also assuming we may support memory operands one day, just not right away.</p>



<a name="200381556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200381556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200381556">(Jun 10 2020 at 06:12)</a>:</h4>
<p>Sure, the main issue with memory operands is that there are tons of arch-specific variants.</p>



<a name="200381632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200381632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200381632">(Jun 10 2020 at 06:14)</a>:</h4>
<p>Right.</p>



<a name="200381635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/named%20explicit%20registers/near/200381635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/named.20explicit.20registers.html#200381635">(Jun 10 2020 at 06:14)</a>:</h4>
<p>It's probably easier to support "this can be in memory", and much harder to support "this must use this particular form of addressing".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>